from xjlibrary.our_file_dir import BaseDir

curpath = BaseDir.get_file_dir_absolute(__file__)
TopPath = BaseDir.get_upper_dir(curpath, -2)
dirPath = BaseDir.get_new_path(TopPath, "download", "intlpress", "download", "cover")


class MapCover(object):

    def __init__(self):
        self.nCount = 0
        self.provider = 'intlpressjournal'
        self.filePath = self.provider + '_cover.txt'

    def map(self):
        with open(self.filePath, mode='w', encoding='utf-8') as f:
            for file in BaseDir.get_dir_all_files(dirPath):
                filename = BaseDir.get_filename_not_extsep(file)
                filename2 = BaseDir.get_file_name(file)
                line = self.provider + '@' + filename + '★/smartlib/' + self.provider + '/' + filename2 + '\n'
                f.write(line)
                self.nCount += 1
                print(self.nCount)


def main():
    mapcovre = MapCover()
    mapcovre.map()


if __name__ == "__main__":
    main()
